package com.cheyun.netsalev3.view

import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.adapter.MyAdapter
import com.cheyun.netsalev3.databinding.ActivityWorkSwitchBinding
import com.cheyun.netsalev3.utils.BaseActivity
import com.cheyun.netsalev3.utils.InjectorUtils
import com.cheyun.netsalev3.viewmodel.WorkSwitchActivityViewModel

class WorkSwitchActivity : BaseActivity<ActivityWorkSwitchBinding>() {
    override fun initContentView(): Int {
        return R.layout.activity_work_switch

    }

    override fun initViewModel(): ViewModel? {
        var factory = InjectorUtils.getWorkSwitchViewModelFactory()
        return ViewModelProviders.of(this, factory).get(WorkSwitchActivityViewModel::class.java)
    }

    lateinit var adapter: MyAdapter
    override fun initView() {
        adapter = MyAdapter(R.layout.work_switch_item, binding.viewModel)
        binding.recyclerView.adapter = adapter
    }

    override fun initData() {
        binding.viewModel?.listview?.observe(this, Observer { lists ->
            adapter.submitList(lists)
        })
    }

}
